package com.wc5818.wcFlow.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wc5818.common.AjaxResult;
import com.wc5818.service.WorkflowService;
import com.wc5818.wcComOrder.entity.WcComOrder;
import com.wc5818.wcFlow.entity.WcFlow;
import com.wc5818.wcFlow.mapper.WcFlowMapper;
import com.wc5818.wcWorkflowChulr.entity.WcWorkflowChulr;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2020-02-20
 */
@RestController
@RequestMapping("/wcFlow")
public class WcFlowController {
    @Autowired
    WcFlowMapper wcFlowMapper;

    @Autowired
    WorkflowService workflowService;

    TaskService taskService;


    @GetMapping("/getwcflow")
    public Object complete(String orderNum) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        WcFlow wf = wcFlowMapper.selectOne(new QueryWrapper<WcFlow>().eq("ordernum", orderNum));
        System.err.println("::::::::::::::::::asasasa::::::::" + wf.toString());
        if (wf != null) {
            ajaxResult.setData(wf);
            ajaxResult.setSuccess(true);
        }
        return ajaxResult;
    }

    /**
     * 根据任务tasklist获取订单号
     */
    @GetMapping("/getwcflowUserid")
    public Object getWcflowUserid(String userId) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);

        List<WcComOrder> list = workflowService.taskList(userId);
        if(list!=null){
        ajaxResult.setSuccess(true);

        }
        return ajaxResult;
    }
}
